package com.jy.rhin.config.infra;

import com.jy.framework.base.entity.Result;
import com.jy.rhin.infra.exception.RhinInfraException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author WeiQ
 * @date 2022/6/22 16:07
 */
@Slf4j
@RestControllerAdvice
public class RhinGlobalExceptionHandlerAdvice {

    @ExceptionHandler({RhinInfraException.class})
    public Result<String> baseException(RhinInfraException ex) {
        log.error("base exception:{}", ex.getMessage());
        return Result.fail(ex.getErrorType(), ex.getMessage());
    }

}
